import {
  BookModel
} from "../../models/book.js";
import {
  random
} from "../../utils/common.js";

var bookModel = new BookModel();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    books: [],
    searching: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    bookModel.getHotList()
      .then(res => {
        this.setData({
          books: res.data
        })
      })
  },

  searchTap: function(event) {
    this.setData({
      searching: true
    })
  },

  cancel: function(event) {
    this.setData({
      searching: false
    })
  },

  onReachBottom: function() {
    this.setData({
      more: random(16)
    })
  },

})